package org.budo.phone.api.response;

/**
 * @author lmw
 */
public enum AgentState {
    Idle(0), Waiting(1), Receiving(2), InCall(3);

    private Integer intValue;

    AgentState(Integer intValue) {
        this.intValue = intValue;
    }

    public static AgentState ofString(String state) {
        if (null == state) {
            return null;
        }

        if ("Idle".equals(state)) {
            return Idle;
        }

        if ("Waiting".equals(state)) {
            return Waiting;
        }

        if ("Receiving".equals(state)) {
            return Receiving;
        }

        if ("In a queue call".equals(state)) {
            return InCall;
        }

        if ("-ERR Agent not found!".equals(state)) {
            return null;
        }

        if ("-ERR callcenter_config Command not found!".equals(state)) {
            return null;
        }

        throw new RuntimeException("#80 state=" + state);
    }

    public Integer toInt() {
        return this.intValue;
    }
}